#include <iostream>
#include <sstream>
#include <iostream>
#include <string>

#include "Student.h"
#include "StudentRegister.h"
using namespace std;

void main3_1()
{
	Student s1;
	Student s2("Zlatan","Ibrahimovic",1999);
	s1.SetFirstName("Henrik");
	s1.SetSecondName("Larsson");
	s1.SetEnrollmentYear(1994);
	cout << "s1 Firstname = " << s1.GetFirstName() << endl;
	cout << "s1 Secondname = " << s1.GetSecondName() << endl;
	cout << "s1 Enrollmentyear= " << s1.GetEnrollmentYear() << endl;
	cout << "s2 Firstname = " << s2.GetFirstName() << endl;
	cout << "s2 Secondname = " << s2.GetSecondName() << endl;
	cout << "s2 Enrollmentyear = " << s2.GetEnrollmentYear() << endl;
}
void main3_2()
{
	Student s1;
	s1.Read();
	s1.Write();
}
void main3_3()
{
	istringstream iss("Gunnar,Nordahl,1992");
	Student s1;
	iss >> s1;
	cout << s1;
}
void main3_4()
{
	Student s1("Zlatan","Ibrahimovic",1999);
	Student s2("Joe","Hart",1997);
	Student s3("Harry","Kewell",1991);
	StudentRegister sr;
	sr.AddStudent(s1);
	sr.AddStudent(s2);
	sr.AddStudent(s3);
	cout << sr.List();
}
void main3_5()
{
	Student s1("Zlatan","Ibrahimovic",1999);
	Student s2("Joe","Hart",1997);
	Student s3("Harry","Kewell",1991);
	StudentRegister sr;
	sr.AddStudent(s1);
	sr.AddStudent(s2);
	sr.AddStudent(s3);
	sr.Write2File("studentregister.txt");
}
void main3_6()
{
	StudentRegister sr;
	sr.ReadFromFile("studentregister.txt");
	cout << sr.List();
}
void main4()
{
	StudentRegister sr;
	Student s1;
	while(true)
	{
		int i = 0;
		cout << "1. Add student to register" << endl;
		cout << "2. Remove student from register" << endl;
		cout << "3. Add course to student" << endl;
		cout << "4. Add result, for specific course and student" << endl;
		cout << "5. Save all to file" << endl;
		cout << "6. Read all from file" << endl;
		cout << "7. Print out the Student register" << endl;
		cin >> i;
		if(i == 1)
		{
			s1 = Student();
			s1.Read();
			sr.AddStudent(s1);
		}
		if(i == 2)
		{
			sr.RemoveStudentFromRegister();
		}
		if(i == 3)
		{
			sr.AddNewCourse();
		}
		if(i == 4)
		{
			sr.AddNewResult();
		}
		if(i == 5)
		{
			sr.PrintAllToFile("bigregister.txt");
		}
		if(i == 6)
		{
			sr.ReadAllFromFile("bigregister.txt");
		}
		if(i == 7)
		{
			cout << sr.List();
		}
	}
}
int main()
{

	//main3_1();
	//main3_2();
	//main3_3();
	//main3_4();
	//main3_5();
	//main3_6();
	main4();
	cout << endl;
	system("PAUSE");
	return 0;
}